home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / PASSDK30.ZIP;1 / DISK1.ZIP / PAS / PCM / RECFILE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-26  |  19.2 KB  |  897 lines

  1. /*$Author:   DCODY  $*/
  2. /*$Date:   26 Jan 1993 16:41:42  $*/
  3. /*$Header:   X:/sccs/pcmapps/recfile.c_v   1.13   26 Jan 1993 16:41:42   DCODY  $*/
  4. /*$Log:   X:/sccs/pcmapps/recfile.c_v  $
  5.  * 
  6.  *    Rev 1.13   26 Jan 1993 16:41:42   DCODY
  7.  * updated recfile.c to fix a bug in creating .VOC files.
  8.  * 
  9.  *    Rev 1.12   06 Oct 1992 15:21:10   DCODY
  10.  * corrected a bug in writing the RIFF data size
  11.  * 
  12.  *    Rev 1.11   24 Sep 1992 08:59:04   DCODY
  13.  * changed MVGetHardware to mvGetHardware
  14.  * 
  15.  *    Rev 1.10   18 Sep 1992 08:47:58   DCODY
  16.  * added '+' option to the 'M' switch.
  17.  * 
  18.  *    Rev 1.9   14 Sep 1992 17:23:50   SHAO_M
  19.  * Put all the text strings used in printf into rectext.h
  20.  * 
  21.  *    Rev 1.0   14 Sep 1992 17:02:20   unknown
  22.  * Initial revision.
  23.  * 
  24.  *    Rev 1.8   02 Sep 1992 12:48:52   DCODY
  25.  * made one simple change that now allows 44khz stereo 16bit recordings.
  26.  * Took out the writting of the WAV header before starting the record
  27.  * process. It is now done after the recording is finished. This allows
  28.  * the data blocks to be written on sector boundaries.
  29.  * 
  30.  *    Rev 1.7   20 Aug 1992 14:36:28   DCODY
  31.  * error exit now reports proper T&L product name.
  32.  * 
  33.  *    Rev 1.6   04 Aug 1992 11:39:42   DCODY
  34.  * corrected t&l spelling
  35.  * 
  36.  *    Rev 1.5   28 Jul 1992 14:29:30   DCODY
  37.  * updated for Thunderboard and Thunder&Lightning
  38.  * 
  39.  *    Rev 1.4   20 Jul 1992 11:39:18   DCODY
  40.  * call to mvGetHWVersion now uses active I/O address detection.
  41.  * 
  42.  *    Rev 1.3   13 Jul 1992 18:54:00   DCODY
  43.  * removed initmvsound call
  44.  * 
  45.  *    Rev 1.2   01 Jul 1992 11:57:16   DCODY
  46.  * GaryL: Added OEM compiler flag checking for Welcome()
  47.  * to use the generic board name and to not displau the MVI copyright.
  48.  * Note that the copyright is still present, as an imbedded static string.
  49.  * 
  50.  *    Rev 1.1   23 Jun 1992 16:10:02   DCODY
  51.  * pas2 update...
  52.  * 
  53.  *    Rev 1.0   15 Jun 1992 09:26:48   BCRANE
  54.  * Initial revision.
  55. */
  56. /*$Logfile:   X:/sccs/pcmapps/recfile.c_v  $*/
  57. /*$Modtimes$*/
  58. /*$Revision:   1.13  $*/
  59. /*$Workfile:   recfile.c  $*/
  60.  
  61.  
  62.     /*\
  63.     |*|----====< RECFILE.C >====----
  64.     |*|
  65.     |*| Record 8 bit PCM to disk in .WAV format
  66.     |*|
  67.     |*| Copyright (c) 1991, Media Vision, Inc. All rights reserved.
  68.     |*|
  69.     \*/
  70.  
  71. #ifndef OEM
  72. #define OEM 0
  73. #endif
  74.  
  75. #ifndef PROAS
  76. #define PROAS 0
  77. #endif
  78.  
  79. #ifndef THUNDER
  80. #define THUNDER 0
  81. #endif
  82.  
  83. #include <stdio.h>
  84. #include <stdlib.h>
  85. #include <malloc.h>
  86. #include <signal.h>
  87. #include "rectext.h"
  88.  
  89.  
  90. #if PROAS
  91. #include "play.h"
  92. #include "common.h"
  93. #include "pcmio.h"
  94. #include "binary.h"
  95. #endif
  96.  
  97. #if THUNDER
  98. #include "proto.h"
  99. #include "play.h"
  100. #include "common.h"
  101. #include "pcmio.h"
  102. #endif
  103.  
  104.  
  105.     /*\
  106.     |*|----====< Global Variables >====----
  107.     \*/
  108.  
  109.         extern int ProcessedBlockCount;
  110.  
  111.         long mvGetHWVersion (int);
  112.  
  113.  
  114.     /*\
  115.     |*|----====< Local Variables >====----
  116.     \*/
  117.  
  118.         static FILE *ouf = 0;           /* temp output file             */
  119.  
  120.         static long SampleRate = 11025L;/* default sample rate          */
  121.         static int  StereoMono = 0;     /* default to mono              */
  122.  
  123.         static char TargetFile[100];    /* holds output file name       */
  124.         static int    FilterIndex = -1;    /* -1 means no override         */
  125.  
  126.         static int    DMAChannel = -1;    /* default to standard DMA        */
  127.         static int    IRQChannel = -1;    /* default to standard IRQ        */
  128.  
  129.         static int    DebugFlag = FALSE;
  130.         static int    Compression = 0;        /* no compression - 8 bits    */
  131.  
  132.         static int  VoiceActivated = FALSE;
  133.         static int    VoiceActivatedNonStop = FALSE;
  134.         static int    NoiseLevel = 5;
  135.  
  136.         static int    maxsize = 16;        /* 16k DMA buffer size            */
  137.         static int    maxdiv    = 4;        /* 4k divisions on the DMA        */
  138.         static int    datasize= 8;        /* 8 or 16 bit samples            */
  139.         static long TheBoardVersion = 0;/* the board version            */
  140.  
  141. #define WAVEFILE    1
  142. #define VOCFILE     2
  143.         static int    FileType;
  144.  
  145.     /*\
  146.     |*|----====< Data Structures >====----
  147.     \*/
  148.  
  149.         RiffWave fhd = {
  150.             { "RIFF", 0L },
  151.             { "WAVE",
  152.                 { "fmt ", sizeof(WaveInfo) , { 1, 1, 11025L, 11025L, 1, 8}, },
  153.                 { "data", 0L },
  154.             }
  155.         };
  156.  
  157.     /* .VOC simple (cheat) header definition                            */
  158.  
  159.         typedef struct {
  160.             VOCHDR     vhdr;
  161.             bVOCDATA vdta;
  162.         } VOCHeader;
  163.  
  164.     /* our pre-defined data block                                        */
  165.  
  166.         static VOCHeader vhd = {
  167.             { "Creative Voice File\x1a", 0x001a, 0x010a, 0x1129 },
  168.             { 0x01, 0x0,0x0,0x0, 0xa5, 0x0 }
  169.         };
  170.  
  171.  
  172.     /*\
  173.     |*|-----------------=============================-------------------
  174.     |*|-----------------====< Start of Exection >====-------------------
  175.     |*|-----------------=============================-------------------
  176.     \*/
  177.  
  178.     /*\
  179.     |*|----====< Main >====----
  180.     |*|
  181.     |*| Play the voice file out to the PCM hardware
  182.     |*|
  183.     \*/
  184.  
  185. main(argc,argv)
  186.     int  argc;
  187.     char *argv[];
  188. {
  189. char c;
  190.  
  191.     /* Give the welcome & checkout the hardware                         */
  192.  
  193.         Welcome();
  194.  
  195.     /* disable the ^C                                                   */
  196.  
  197.         signal(SIGINT,SIG_IGN);
  198.  
  199.     /* set the runtime switches                                         */
  200.  
  201.         CommandLine (argc,argv);
  202.  
  203.     /* need a file name to play, exit if not found                      */
  204.  
  205.         PreProcessFile (TargetFile);
  206.  
  207. #if THUNDER
  208.     /* last minute weirdness check...                                    */
  209.  
  210.         LastChanceStop();
  211. #endif
  212.  
  213. #if PROAS
  214.     /* turn off the digital input mixer channel to avoid feedback       */
  215.  
  216.         TurnItOff();
  217.  
  218. #endif
  219.  
  220.     /* setup the DMA operations                                         */
  221.  
  222.         if (OpenPCMBuffering(DMAChannel,IRQChannel,maxsize,maxdiv)) {
  223.             printf (TXT_MSG1);
  224.             DoExit (-1);
  225.         }
  226.  
  227.     /* setup how this file sounds                                        */
  228.  
  229. #if PROAS
  230.         ChooseFilter( SampleRate, FilterIndex );
  231. #endif
  232.  
  233.         PCMState (SampleRate, StereoMono, Compression, datasize);
  234.  
  235.     /* Start the DMA & wait till an ESC is typed or data ends           */
  236.  
  237.         printf (TXT_MSG2);
  238.  
  239.         if (StartFileInput( ouf )) {
  240.  
  241.             while (1) {
  242.  
  243.                 /* process some PCM data, if available                    */
  244.  
  245.                     if (VoiceActivated) {
  246.                         if (!ASpecialContinueFileInput(NoiseLevel,VoiceActivatedNonStop))
  247.                             DoExit(PCMIOERR_FILEFULL);
  248.                     }
  249.                     else {
  250.                         if (!ContinueFileInput())
  251.                             DoExit(PCMIOERR_FILEFULL);
  252.                     }
  253.  
  254.                 /* if ESC typed, kill the DMA & exit                    */
  255.  
  256.                     if (kbhit()) {
  257.                         if ((c = getch()) == 0x1b) {
  258.                             StopDMAIO();
  259.                             break;
  260.                         }
  261.                         if (c == ' ') {
  262.                             PausePCM();
  263.                             printf (TXT_MSG3);
  264.                             GetKey();
  265.                             printf (TXT_MSG4);
  266.                             ResumePCM();
  267.                         }
  268.                     }
  269.             }
  270.         }
  271.         else
  272.             DoExit (PCMIOERR_OPENPCM);
  273.  
  274.     /* exit to DOS                                                      */
  275.  
  276.         DoExit(0);
  277.  
  278. }
  279.  
  280.     /*\
  281.     |*|--------------------=======================----------------------
  282.     |*|--------------------====< Subroutines >====----------------------
  283.     |*|--------------------=======================----------------------
  284.     \*/
  285.  
  286.  
  287.     /*\
  288.     |*|----====< BuildFileName( char *, char *, char *, int ); >====----
  289.     |*|
  290.     |*| This routine takes the source name, scans it for an extension,
  291.     |*| then may append the new extension. The entire file name is
  292.     |*| returned in the callers target string.
  293.     |*|
  294.     \*/
  295. void BuildFileName(trg,src,ext,force)
  296.     char *trg;
  297.     char *src;
  298.     char *ext;
  299.     int force;
  300. {
  301. int n;
  302. char *t,*o;
  303.  
  304.     // save a copy of the starting target address
  305.  
  306.         o = trg;
  307.  
  308.     // copy the source over to the target
  309.  
  310.         while ((*trg++ = *src++)) ;
  311.  
  312.     // move back to the terminator and save the pointer
  313.  
  314.         t = --trg;
  315.  
  316.     // search for an extension, if found, just return, we're all done...
  317.  
  318.         for (n=0;n<=4;n++) {
  319.  
  320.             // if no extension, go add one...
  321.  
  322.             if (o == trg)
  323.                 break;
  324.  
  325.             // if an extension...
  326.  
  327.             if (*trg == '.') {
  328.  
  329.                 // and do not force it, just return.
  330.  
  331.                 if (!force)
  332.                     return;
  333.  
  334.                 // else point to this extension, and break out...
  335.  
  336.                 else {
  337.                     t = trg;
  338.                     break;
  339.                 }
  340.             }
  341.  
  342.             // move back to the prior character
  343.  
  344.             trg--;
  345.         }
  346.  
  347.     // add the extension
  348.  
  349.         strcpy (t,ext);
  350.  
  351. }
  352.  
  353.  
  354.     /*\
  355.     |*|----====< CommandLine >====----
  356.     |*|
  357.     |*| process the command line switches
  358.     |*|
  359.     \*/
  360. int CommandLine(argc,argv)
  361.     int argc;
  362.     char *argv[];
  363. {
  364. char *s;
  365. int n,temp;
  366. long l;
  367.  
  368.     /* exit if no additional parameters                                 */
  369.  
  370.         if (argc < 2) {
  371.             GiveHelps();
  372.             DoExit(-1);
  373.         }
  374.  
  375.         n = 2;
  376.         while (n < argc) {
  377.  
  378.             s = argv[n++];
  379.  
  380.             if (*s == '/') s++;
  381.             if (*s == '-') s++;
  382.  
  383.             switch (*s & 0x5f) {
  384.  
  385. #if THUNDER
  386.                 case 'C':
  387.                     if (isdigit(*++s)) {
  388.                         switch (*s) {
  389.                             case '0':
  390.                                 Compression = 00;    // 1-to-1,    no compression
  391.                                 break;
  392.  
  393.                             case '1':
  394.                                 Compression = 01;    // 2-to-1,    4 bit compression
  395.                                 break;
  396.  
  397.                             case '2':
  398.                                 Compression = 02;    // 3-to-1,    2.6 bit compression
  399.                                 break;
  400.  
  401.                             case '3':
  402.                                 Compression = 03;    // 4-to-1,    2 bit compression
  403.                                 break;
  404.                         }
  405.                     }
  406.                     else
  407.                         Compression = 01;    // 2-to-1,    4 bit compression
  408.  
  409.                     break;
  410. #endif
  411.  
  412. #if PROAS
  413.                 case '8' & 0x5f:
  414.                 case '1' & 0x5f:
  415.                     if (*++s == '6')
  416.                         datasize = 16;
  417.                     break;
  418.  
  419.                 case 'F':
  420.                     FilterIndex = *++s - 0x30;
  421.                     if ((FilterIndex<0) || (FilterIndex>6))
  422.                         FilterIndex = -1;
  423.                     break;
  424. #endif
  425.  
  426.                 case 'D':
  427.                     temp = *++s - 0x30;
  428.                     if ((temp <= 7) && (temp >= 1)) {
  429.                         if (temp == 4) temp = 0;
  430.                         DMAChannel = temp;
  431.                     }
  432.                     break;
  433.  
  434.                 case 'I':
  435.                     if (sscanf (++s,"%d",&temp) == 1) {
  436.                         if ((1 << temp) & 0x9CBC)
  437.                             IRQChannel = temp;
  438.                     }
  439.                     break;
  440.  
  441.                 case 'M':
  442.                     maxsize = 64;
  443.                     maxdiv    = 16;
  444.                     if (*++s == '+')
  445.                         maxdiv    = 4;
  446.                     break;
  447.  
  448.                 case 'R':
  449.                     if (sscanf (++s,"%ld",&SampleRate) != 1) {
  450.                         printf (TXT_MSG5,s);
  451.                         SampleRate = 11025L;
  452.                     }
  453.                     if ((SampleRate < 4000L) || (SampleRate > 44100L)) {
  454.                         printf (TXT_MSG5,s);
  455.                         SampleRate = 11025L;
  456.                     }
  457.                     break;
  458.  
  459.                 case 'S':
  460.                     StereoMono = 1;
  461.                     break;
  462.  
  463.                 case 'V':
  464.                     VoiceActivated = TRUE;
  465.                     if (*(s+1) == '+') {
  466.                         VoiceActivatedNonStop = TRUE;
  467.                         s++;
  468.                     }
  469.                     if (sscanf (++s,"%d",&temp) == 1)
  470.                         NoiseLevel = temp;
  471.                     break;
  472.  
  473.                 case '+' & 0x5f:
  474.                     DebugFlag = TRUE;
  475.                     break;
  476.  
  477.                 default:
  478.                     break;
  479.             }
  480.         }
  481.  
  482.     /* determine the type of output file                                */
  483.  
  484.         BuildFileName (TargetFile,argv[1],".WAV",FALSE);
  485.  
  486.     /* scan the last portion of the name for the type                    */
  487.  
  488.         FileType = WAVEFILE;
  489.         s = TargetFile;
  490.         while (*s) s++;
  491.  
  492.         if ((*(s-1) & 0x5f) == 'C')
  493.             if ((*(s-2) & 0x5f) == 'O')
  494.                 if ((*(s-3) & 0x5f) == 'V')
  495.                     FileType = VOCFILE;
  496.  
  497.     /* if a bad sample rate, time to bomb out...                        */
  498.  
  499.         if (FileType == WAVEFILE) {
  500.             if ((SampleRate<<StereoMono) > 88200L) {
  501.                 printf (TXT_MSG6);
  502.                 DoExit(-1);
  503.             }
  504.         }
  505.         else {
  506.             if ((SampleRate<<StereoMono) > 23300L) {
  507.                 printf (TXT_MSG7,l);
  508.                 DoExit(-1);
  509.             }
  510.         }
  511. }
  512.  
  513.  
  514.     /*\
  515.     |*|----====< DoExit() >====----
  516.     |*|
  517.     |*| Exit to DOS
  518.     |*|
  519.     \*/
  520. int DoExit(cc)
  521.     int cc;
  522. {
  523. int zero = 0;
  524.  
  525. #if PROAS
  526.     /* restore the PCM mixer channel                                    */
  527.  
  528.         TurnItOn();
  529. #endif
  530.  
  531.     /* print any error messages                                         */
  532.  
  533.         switch (cc) {
  534.  
  535.             case PCMIOERR_SAMPLERATE:
  536.                 printf (TXT_MSG8);
  537.                 break;
  538.  
  539.             case PCMIOERR_OPENFILE:
  540.                 printf (TXT_MSG9);
  541.                 break;
  542.  
  543.             case PCMIOERR_OPENPCM:
  544.                 printf (TXT_MSG10);
  545.                 break;
  546.  
  547.             case PCMIOERR_NOMEM:
  548.                 printf (TXT_MSG11);
  549.                 break;
  550.  
  551.             case PCMIOERR_BADDMA:
  552.                 printf (TXT_MSG12);
  553.                 break;
  554.  
  555.             case PCMIOERR_BADIRQ:
  556.                 printf (TXT_MSG13);
  557.                 break;
  558.  
  559.             case PCMIOERR_FILEFULL:
  560.                 printf (TXT_MSG14);
  561.                 printf (TXT_MSG15);
  562.                 break;
  563.  
  564.             default:
  565.             case PCMIOERR_HELPS:
  566.                 break;
  567.         }
  568.  
  569.     /* if there is data, flush it and zip up the file                    */
  570.  
  571.         if (ouf) {
  572.  
  573.             if (ProcessedBlockCount) {
  574.  
  575.                 if (FileType == VOCFILE) // set the terminating record
  576.                     _dofwrite ((char far *)&zero,0x01,fileno(ouf));
  577.  
  578.                 fclose (ouf);
  579.  
  580.                 if ((ouf = fopen(TargetFile,"r+b")) == 0) {
  581.                     printf (TXT_MSG16,TargetFile);
  582.                     ClosePCMBuffering();
  583.                     exit(cc);
  584.                 }
  585.  
  586.                 SetupHeader();
  587.                 WriteBlockHeader();
  588.             }
  589.             fclose (ouf);
  590.         }
  591.  
  592.     /* shut down the hardware                                           */
  593.  
  594.         ClosePCMBuffering();
  595.         exit (cc);
  596. }
  597.  
  598.  
  599.     /*\
  600.     |*|----====< GetKey() >====----
  601.     |*|
  602.     |*| Get a new key
  603.     |*|
  604.     \*/
  605. int GetKey()
  606. {
  607. char c;
  608.  
  609.     while (kbhit()) getch();
  610.  
  611.     while (!kbhit()) ;
  612.     if (getch() == 0) getch();
  613.  
  614. }
  615.  
  616.  
  617.     /*\
  618.     |*|----====< GiveHelps >====----
  619.     |*|
  620.     |*| Print the Help messages & returen
  621.     |*|
  622.     \*/
  623. int GiveHelps()
  624. {
  625.  
  626.     /* print & return...                                                */
  627.  
  628. #if PROAS
  629.         printf (TXT_MSG17);
  630.         printf (TXT_MSG18);
  631.         printf (TXT_MSG19);
  632.         printf (TXT_MSG20);
  633.         printf (TXT_MSG21);
  634.         printf (TXT_MSG22);
  635.         printf (TXT_MSG23);
  636.         printf (TXT_MSG24);
  637.         printf (TXT_MSG25);
  638.         printf (TXT_MSG26);
  639.         printf (TXT_MSG27);
  640.         printf (TXT_MSG28);
  641. #endif
  642. #if THUNDER
  643.         printf (TXT_MSG29);
  644.         printf (TXT_MSG30);
  645.         printf (TXT_MSG31);
  646.         printf (TXT_MSG32);
  647.         printf (TXT_MSG32a);
  648.         printf (TXT_MSG32b);
  649.         printf (TXT_MSG32c);
  650.         printf (TXT_MSG32d);
  651.  #if THUNDER==2
  652.         printf (TXT_MSG33);
  653.         printf (TXT_MSG34);
  654.  #else
  655.         printf (TXT_MSG35);
  656.  #endif
  657.         printf (TXT_MSG36);
  658.         printf (TXT_MSG37);
  659.         printf (TXT_MSG38);
  660.         printf (TXT_MSG39);
  661. #endif
  662. }
  663.  
  664. #if THUNDER
  665.     /*\
  666.     |*|----====< LastChanceStop() >====----
  667.     |*|
  668.     |*| Stop if there are some illegal setups
  669.     |*|
  670.     \*/
  671. LastChanceStop()
  672. {
  673.  
  674.     /* .WAV cannot support compression...                                */
  675.  
  676.         if ((FileType == WAVEFILE) && (Compression)) {
  677.             printf (TXT_MSG40);
  678.             GiveHelps();
  679.             DoExit(-1);
  680.         }
  681. }
  682. #endif
  683.  
  684.     /*\
  685.     |*|----====< PreProcessFile >====----
  686.     |*|
  687.     |*| Validate the User's output file & load the 1st header block
  688.     |*|
  689.     \*/
  690. int PreProcessFile (fn)
  691.     char *fn;
  692. {
  693.  
  694.     /* see if the file already exists                                   */
  695.  
  696.         if ((ouf = fopen(fn,"rb"))) {
  697.  
  698.             printf (TXT_MSG41,fn);
  699.  
  700.             while (!kbhit()) ;
  701.  
  702.             if ((getchar() & 0x5f) != 'Y') {
  703. #if PROAS
  704.                 TurnItOn();
  705. #endif
  706.                 exit(1);
  707.             }
  708.             fclose (ouf);
  709.         }
  710.  
  711.     /* attempt to open the users disk file                              */
  712.  
  713.         if ((ouf = fopen(fn,"wb")) == 0) {
  714.             printf (TXT_MSG42,fn);
  715.             DoExit (-1);
  716.         }
  717.  
  718.     /* send the header to disk                                          */
  719.  
  720. ////////WriteBlockHeader();
  721.  
  722. }
  723.  
  724.  
  725.     /*\
  726.     |*|----====< SetupHeader >====----
  727.     |*|
  728.     |*| Load the RIFF header with the critical data
  729.     |*|
  730.     \*/
  731. int SetupHeader()
  732. {
  733. long l,n;
  734.  
  735.     /* calculate the block size of each buffer division                 */
  736.  
  737.         n = maxsize / maxdiv * 1024;
  738.  
  739.     /* get the # of processed blocks                                    */
  740.  
  741.         l = LONG(ProcessedBlockCount) * n - sizeof(RiffWave);
  742.  
  743.     /* set the data size                                                */
  744.  
  745.         fhd.wave.data.length = l;
  746.  
  747.     /* set the RIFF length                                              */
  748.  
  749.         fhd.riff.length = l + sizeof(WaveHeader);
  750.  
  751.     /* set the length of the FORMAT block                               */
  752.  
  753.         fhd.wave.fmt.length = sizeof(WaveInfo);
  754.  
  755.     /* set up the sample rate, etc...                                   */
  756.  
  757.         fhd.wave.fmt.info.nChannels        = StereoMono + 1;
  758.         fhd.wave.fmt.info.nSamplesPerSec   = SampleRate;
  759.         fhd.wave.fmt.info.nAvgBytesPerSec  = (SampleRate << StereoMono) <<
  760.                                                 ((datasize == 8) ? 0 : 1);
  761.         fhd.wave.fmt.info.nBlockAlign       = (1 + ((datasize == 8) ? 0 : 1))
  762.                                                 << StereoMono;
  763.         fhd.wave.fmt.info.nBitsPerSample   = datasize;
  764.  
  765.     /* setup the .VOC header                                            */
  766.  
  767.         l = LONG(ProcessedBlockCount)
  768.                 * n - (sizeof(VOCHDR) + sizeof(bVOCDATAHDR));
  769.  
  770.         vhd.vdta.bsize[0] = (char) (l       & 0xff);
  771.         vhd.vdta.bsize[1] = (char)((l>>8)  & 0xff);
  772.         vhd.vdta.bsize[2] = (char)((l>>16) & 0xff);
  773.         vhd.vdta.sampler  = (char)(256-(1000000L/SampleRate)) & 0xff;
  774.         vhd.vdta.packtype = Compression;
  775.  
  776.         if (StereoMono)
  777.             vhd.vdta.packtype = 5;
  778.  
  779. }
  780.  
  781.  
  782.     /*\
  783.     |*|----====< Welcome >====----
  784.     |*|
  785.     |*| Print the logo & check for the appropriate hardware
  786.     |*|
  787.     \*/
  788. Welcome()
  789. {
  790.  
  791.     /* give the normal stuff...                                         */
  792.  
  793. #if OEM
  794.  #if PROAS
  795.         printf (TXT_MSG43);
  796.         {
  797.                 static char    zsCopyright[] = "Copyright (c) 1991,1992 Media Vision, Inc. All Rights Reserved\n\n";
  798.         }
  799.  
  800.         TheBoardVersion = mvGetHWVersion(USE_ACTIVE_ADDR);/* get the version              */
  801.         if (TheBoardVersion == -1) {
  802.             printf (TXT_MSG44);
  803.             GiveHelps();
  804.             exit(-1);
  805.         }
  806.  #endif
  807.  
  808.  #if THUNDER
  809.         printf (TXT_MSG45);
  810.         {
  811.                 static char    zsCopyright[] = "Copyright (c) 1991,1992 Media Vision, Inc. All Rights Reserved\n\n";
  812.         }
  813.  
  814.         TheBoardVersion = InitMVHardware(); /* get the version, or something.. */
  815.         if ((TheBoardVersion < 0) || ((ver & 0xffff0000) != 0x00010000)) {
  816.             printf (TXT_MSG46);
  817.             GiveHelps();
  818.             exit(-1);
  819.         }
  820.  #endif
  821. #else    //OEM
  822.  #if PROAS
  823.         printf (TXT_MSG47);
  824.         printf (TXT_MSG48);
  825.  
  826.         TheBoardVersion = mvGetHWVersion(USE_ACTIVE_ADDR);/* get the version              */
  827.         if (TheBoardVersion == -1) {
  828.             printf (TXT_MSG49);
  829.             GiveHelps();
  830.             exit(-1);
  831.         }
  832.  #endif
  833.  
  834.  #if THUNDER
  835.   #if THUNDER==2
  836.         printf (TXT_MSG50);
  837.   #else
  838.         printf (TXT_MSG51);
  839.   #endif
  840.         printf (TXT_MSG52);
  841.  
  842.         TheBoardVersion = mvGetHWVersion(0);/* get the version, or something.. */
  843.         if ((TheBoardVersion < 0) || ((TheBoardVersion & 0xffff0000) != 0x00010000)) {
  844.   #if THUNDER==2
  845.             printf (TXT_MSG53);
  846.   #else
  847.             printf (TXT_MSG54);
  848.   #endif
  849.             GiveHelps();
  850.             exit(-1);
  851.         }
  852.  #endif
  853. #endif    //OEM
  854.  
  855. }
  856.  
  857.  
  858.     /*\
  859.     |*|----====< WriteBlockHeader >====----
  860.     |*|
  861.     |*| Output the one and only voice block header
  862.     |*|
  863.     \*/
  864.  
  865. int WriteBlockHeader()
  866. {
  867. long l;
  868. char *s;
  869. int n;
  870. WaveFormat wf;
  871.  
  872.     /* point to the start of the file                                   */
  873.  
  874.         fseek (ouf,0L,SEEK_SET);
  875.  
  876.     /* depending on the type of file, output the data...                */
  877.  
  878.         if (FileType == WAVEFILE) {
  879.  
  880.             s = (char*) &fhd;
  881.             for (n=sizeof(RiffWave);n;n--)
  882.                 fputc(*s++,ouf);
  883.         }
  884.         else {
  885.  
  886.             s = (char*) &vhd;
  887.             for (n=sizeof(VOCHeader);n;n--)
  888.                 fputc(*s++,ouf);
  889.         }
  890. }
  891.  
  892.  
  893.     /*\
  894.     |*| end of RECFILE.C
  895.     \*/
  896.  
  897.